<template>
	<view class="page-container">
		<u-navbar autoBack title="设置" bgColor="#ECF6EA" fixed placeholder safeAreaInsetTop></u-navbar>

		<view class="container">
			<view class="edit-item" v-for="(item,index) in editData" :key="index" @click="gonavigate(item.url)">
				<view class="item-left">{{item.name}}</view>
				<u-icon name="arrow-rightward" size="20"></u-icon>
			</view>
			<view class="login-out" @click="logout">
				<button class="publish-btn">退出登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapMutations } from 'vuex'
	export default {
		data() {
			return {
				// 编辑数据
				editData: [{
						name: '我的资料',
						url: 'myInfo'
					},
					{
						name: '绑定手机号',
						url: 'myInfo'
					},
					{
						name: '消息通知',
						url: 'myInfo'
					},
					{
						name: '收货地址',
						url: 'address?userId='+uni.getStorageSync('userId')
					},
					{
						name: '清除缓存',
						url: 'myInfo'
					},
					{
						name: '版本更新',
						url: 'myInfo'
					}
				]
			}
		},
		methods: {
			// 跳转页面
			gonavigate(pageUrl) {
				uni.navigateTo({
					//保留当前页面，跳转到应用内的某个页面
					url: pageUrl
				})
			},
			// 退出登录
			logout() {
				localStorage.removeItem('userId')
				uni.switchTab({
					url: "/pages/index/default/default"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page-container {
		.container {
			.edit-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: $gs-jpBg;
				margin: $uni-spacing-col-sm 0;
				padding: $uni-spacing-col-lg $uni-spacing-row-lg;
			}
			.login-out{
				width: 100%;
				position: fixed;
				bottom: 31px;
				.publish-btn {
					width: 80%;
					color: $uni-bg-color-grey;
					background-color: $gs-btn;
					border-radius: 26px;
				}
			}
		}
	}
</style>